<template>
	<view class="content" style="background-color: #fff;">
		<u-navbar scrollable=false titleStyle="font-size:40rpx;color:#333" :placeholder='true' title="优惠券"
			:autoBack="true">
		</u-navbar>
		<view class="nav">
			<u-tabs  :list="tabs" @click="tabClick" :activeStyle="{ color: '#DD2131',}" lineWidth="48" lineColor="#DD2131" itemStyle="color:'#999999'; padding-left: 15px; 
				width:25%;
				padding-right: 15px; height: 34px;
				padding-top:32rpx;
				padding-bottom:8rpx;
				 font-size:32rpx;  ">
			</u-tabs>
		</view>
		<view class="coupon" >
			<!-- 循环生成优惠券 -->
			<view class="" v-if="state==0" v-for="(item,index) in list" :key="index">
				<view class="">
					<view class="" style="width: 100%;height: 24rpx;"></view>
					<view class="li">
						<view class="li_left">
							<view class="li_left_inner">
								<view class="top">{{item.coupon_type==1?('￥'+item.coupon_price):(item.discount+'折')}}</view>
								<view >{{item.coupon_type==1?'满减券':'折扣券'}}</view>
							</view>
						</view>
						<view class="li_right">
							<view class="li_right_inner">
								<view class="co3 fontS32">{{item.coupon_title}}</view>
								<view class="co9 fontS24">有效期{{item.end_time}}</view>
							</view>
							<view class="li_right_inner_r co9">
								待
								使
								用
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="state==1" v-for="(item,index) in list" :key="index">
				<view class="">
					<view class="" style="width: 100%;height: 24rpx;"></view>
					<view class="li">
						<view class="li_left grayscale ">
							<view class="li_left_inner">
								<view class="top">{{item.coupon_type==1?('￥'+item.coupon_price):(item.discount+'折')}}</view>
								<view >{{item.coupon_type==1?'满减券':'折扣券'}}</view>
							</view>

						</view>
						<view class="li_right">
							<view class="li_right_inner">
								<view class="co3 fontS32">{{item.coupon_title}}</view>
								<view class="co9 fontS24">有效期{{item.end_time}}</view>
							</view>
							<view class="li_right_inner_r co9">
								已
								使
								用
							</view>

						</view>
					</view>
				</view>
			</view>
			<view class="" v-if="state==2" v-for="(item,index) in list" :key="index">
				<view class="">
					<view class="" style="width: 100%;height: 24rpx;"></view>
					<view class="li">
						<view class="li_left grayscale ">
							<view class="li_left_inner">
								<view class="top">{{item.coupon_type==1?('￥'+item.coupon_price):(item.discount+'折')}}</view>
								<view >{{item.coupon_type==1?'满减券':'折扣券'}}</view>
							</view>
						</view>
						<view class="li_right">
							<view class="li_right_inner">
								<view class="co3 fontS32">{{item.coupon_title}}</view>
								<view class="co9 fontS24">有效期{{item.end_time}}</view>
							</view>
							<view class="li_right_inner_r co9">
								已过期
							</view>

						</view>
					</view>
				</view>
				
			</view>

		</view>
		<!-- 无优惠券 -->

		<view class="noCoupon center" :style="style" v-if="list.length==0">
				<image  src="@/static/images/mine/no_coupon.png" style="width:326rpx;height:252rpx;" mode=""></image>
				<view class="co9 fontS28">暂无优惠券~</view>
		</view>
	</view>
</template>



<script>
	export default {
		data() {
			return {
				page:1,
				list:[],
				state: 0,
				tabs: [{
					name: '未使用',
				}, {
					name: '已使用',
				}, {
					name: '已过期'
				}],
				height: '',
				style: '',
			}
		},
		onReachBottom() {
			this.page++;
			this.getList()
		},
		methods: {
			tabClick(item) {
				this.state = item.index
				this.page=1;
				this.getList(true)
			},
			getList(val){ 
				if(val){
					this.page=1;
					this.list=[]
				}
				this.$my.post('/index/coupon/selectUserCoupon',{page:this.page,limit:20,status:this.state+1}).then(res=>{
					if(res.code==200){
						this.list=this.list.concat(res.data.data)
					}
				})
			},
		},
		onLoad() {
			this.getList()
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		.grayscale {
			filter: grayscale(100%);
			-webkit-filter: grayscale(100%);
			-moz-filter: grayscale(100%);
			-ms-filter: grayscale(100%);
			-o-filter: grayscale(100%);
			filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
			-webkit-filter: grayscale(1);
		}

		.nav {
			// background-color: tomato;

		}

		.coupon {
			background-color: #f5f5f5;
			padding-left: 32rpx;
			padding-right: 32rpx;

			.li {
				display: flex;

				.li_left {
					width: 33%;
					height: 180rpx;
					text-align: center;
					background-image: linear-gradient(to right, #FCE6D5 , #FEF2E4);
					.li_left_inner {
						// width: 100%;
						height: 100%;
						background-image: url('@/static/images/mine/Mask group.png');
						background-size: 100%;

						view {
							line-height: 30rpx;
							font-size: 30rpx;
						}
						.top {
							line-height: 120rpx;
							font-size: 50rpx;
						}
					}
				}

				.li_right {
					width: 67%;
					height: 180rpx;
					background-color: #fff;
					display: flex;

					.li_right_inner {
						padding-left: 40rpx;
						padding-top: 42rpx;
						width: 88%;
						border-right: 2rpx dashed #f5f5f5;

						.co9 {
							margin-top: 10rpx;
						}
					}

					.li_right_inner_r {
						padding: 20rpx 0;
						width: 12%;
						background-color: white;
						text-align: center;
						line-height: 48rpx;
					}
				}
			}

		}

		.noCoupon {
			padding-top: 220rpx;
		}
	}
</style>
